<template>
	<div class="game-container report-container">
		<div class="view-container dealer-container">
			<SetCustomVoice
				:switchTitle="$t('dxn.service_manager.custom_voice')"
				:configItem="customeVoiceConfig"
				@getValueAddedConfigByTypes="getValueAddedConfigByTypes"
			></SetCustomVoice>
			<UnPublicCards
				:switchTitle="$t('dxn.service_manager.un_public_cards')"
				:configItem="unPublicCardsConfig"
				@getValueAddedConfigByTypes="getValueAddedConfigByTypes"
			></UnPublicCards>
			<ActionDelay
				switchTitle="下注行动延时"
				:configItem="bettingActionDelayConfig"
				@getValueAddedConfigByTypes="getValueAddedConfigByTypes"
			></ActionDelay>
			<ActionDelay
				switchTitle="保险行动延时"
				:configItem="insureActionDelayConfig"
				@getValueAddedConfigByTypes="getValueAddedConfigByTypes"
			></ActionDelay>
			<InteractionProps
				switchTitle="互动道具"
				:configItem="interactionPropsConfig"
				@getValueAddedConfigByTypes="getValueAddedConfigByTypes"
			></InteractionProps>
			<RewardItem
				switchTitle="打赏"
				:configItem="rewardItemConfig"
				@getValueAddedConfigByTypes="getValueAddedConfigByTypes"
			></RewardItem>
		</div>
	</div>
</template>

<script>
import list from '@/mixins/list'
import { routerNames } from '@/utils/consts'
import SetCustomVoice from './components/setCustomVoice'
import ActionDelay from './components/actionDelay'
import UnPublicCards from './components/unPublicCards'
import InteractionProps from './components/interactionProps'
import RewardItem from './components/rewardItem'
export default {
	name: routerNames.customVoice,
	components: {
		SetCustomVoice,
		UnPublicCards,
		ActionDelay,
		InteractionProps,
		RewardItem
	},
	mixins: [list],
	data() {
		return {
			customeVoiceConfig: {},
			unPublicCardsConfig: {},
			bettingActionDelayConfig: {},
			insureActionDelayConfig: {},
			interactionPropsConfig: {},
			rewardItemConfig: {}
		}
	},
	created() {
		this.getValueAddedConfigByTypes()
	},
	methods: {
		getValueAddedConfigByTypes(configType = 0) {
			// 4: 自定义语音, 5: 查看未发公牌,11: 行动延时,14: 互动道具,15: 下注行动延时,16: 保险行动延时
			// 53：打赏
			const params = { types: [4, 5, 14, 15, 16, 53] }
			if (configType) {
				params.types = [configType]
			}
			this.$api.getValueAddedConfigByTypesBend(params).then((res) => {
				if (res?.code === 200 && Array.isArray(res?.data)) {
					res.data.forEach((item) => {
						this.formatValueAddedConfig(item)
					})
				}
			})
		},
		formatValueAddedConfig(item) {
			const basicConfig = {
				configId: item.id,
				configType: item.type,
				configStatus: item.vals?.enableFlag
			}
			switch (item.type) {
				case 4:
					// 自定义语音
					this.customeVoiceConfig = {
						...basicConfig,
						sendMessageInterval: item.vals?.sendMessageInterval,
						recordTotalTime: item.vals?.recordTotalTime
					}
					break
				case 5:
					// 查看未发公牌
					this.unPublicCardsConfig = {
						...basicConfig,
						perTableCount: item.vals?.perTableCount
					}
					break
				case 15:
					// 下注行动延时
					this.bettingActionDelayConfig = {
						...basicConfig,
						// perTableCount: item.vals?.perTableCount,
						// perMoveCount: item.vals?.perMoveCount,
						overTime: item.vals?.overTime
					}
					break
				case 16:
					// 保险行动延时
					this.insureActionDelayConfig = {
						...basicConfig,
						// perTableCount: item.vals?.perTableCount,
						// perMoveCount: item.vals?.perMoveCount,
						overTime: item.vals?.overTime
					}
					break
				case 14:
					// 互动道具
					this.interactionPropsConfig = {
						...basicConfig,
						sendInterval: item.vals?.sendInterval,
						intervalCount: item.vals?.intervalCount,
						forcePay: item.vals?.forcePay
					}
					break
				case 53:
					// 打赏
					this.rewardItemConfig = {
						...basicConfig,
						feeRate: item.vals?.feeRate,
						lowerLimit: item.vals?.lowerLimit,
						amount: item.vals?.amount,
						forcePay: item.vals?.forcePay
					}
					break
			}
		}
	}
}
</script>
